package com.lantosec.hmrp.modules.archives.controller;


import com.lantosec.hmrp.core.log.ControllerLog;
import com.lantosec.hmrp.core.log.LogType;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.modules.archives.entity.UserHappyFuneral;
import com.lantosec.hmrp.modules.archives.service.IUserHappyFuneralService;
import com.lantosec.hmrp.modules.archives.vo.UserHappyFuneralVO;

import java.util.Arrays;
import java.util.List;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RestController;
import com.lantosec.hmrp.core.mvc.BaseController;

/**
 *
 * 领导干部参与操办本人及近亲属婚丧喜庆事宜情况报告表 控制器
 *
 * @author AutoCode
 * @since 2020-06-14
 */
@Api(value = "领导干部参与操办本人及近亲属婚丧喜庆事宜情况报告表控制器", tags = "领导干部参与操办本人及近亲属婚丧喜庆事宜情况报告表控制器")
@RestController
@RequestMapping("/archives/user/happy/funeral")
@Log4j2
public class UserHappyFuneralController extends BaseController {
    @Autowired
    private IUserHappyFuneralService service;

    @GetMapping("getUserHappyFuneral/{userId}")
    @ApiOperation(value = "查询领导干部参与操办本人及近亲属婚丧喜庆事信息")
    public Result<List<UserHappyFuneralVO>> getUserHappyFuneral(@ApiParam(value = "userId", required = true) @PathVariable(name = "userId") String userId) {
        List<UserHappyFuneralVO> userHappyFuneralVOList = service.getUserHappyFuneral(userId);
        return Result.ok(userHappyFuneralVOList);
    }

    @GetMapping("getUserHappyFuneralVerify/{userId}")
    @ApiOperation(value = "查询领导干部参与操办本人及近亲属婚丧喜庆事信息审核列表")
    public Result<List<UserHappyFuneralVO>> getUserHappyFuneralVerify(@ApiParam(value = "userId", required = true) @PathVariable(name = "userId") String userId) {
        List<UserHappyFuneralVO> userHappyFuneralVOList = service.getUserHappyFuneralVerify(userId);
        return Result.ok(userHappyFuneralVOList);
    }

    @PutMapping("verifyUserHappyFuneral")
    @ApiOperation(value = "审核")
    public Result<Void> verifyUserHappyFuneral(@ApiParam(value = "用户任职信息表VO对象", required = true) @RequestBody UserHappyFuneralVO vo) {
        service.verifyUserHappyFuneral(vo);
        return Result.ok();
    }

    @GetMapping("getUserHappyFuneralHistory/{userId}")
    @ApiOperation(value = "查询领导干部参与操办本人及近亲属婚丧喜庆事历史列表")
    public Result<List<UserHappyFuneralVO>> getUserHappyFuneralHistory(@ApiParam(value = "userId", required = true) @PathVariable(name = "userId") String userId) {
        List<UserHappyFuneralVO> userHappyFuneralVOList = service.getUserHappyFuneralHistory(userId);
        return Result.ok(userHappyFuneralVOList);
    }

    @PostMapping("create")
    @ControllerLog(name = "新增领导干部参与操办本人及近亲属婚丧喜庆事宜情况", type = LogType.add)
    @ApiOperation(value = "新增数据")
    public Result<String> create(@ApiParam(value = "领导干部参与操办本人及近亲属婚丧喜庆事宜情况报告表VO对象", required = true) @RequestBody @Validated UserHappyFuneralVO vo){
        service.saveUserHappyFuneral(vo);
        return Result.ok();
    }

    @PutMapping("update")
    @ControllerLog(name = "修改领导干部参与操办本人及近亲属婚丧喜庆事宜情况", type = LogType.update)
    @ApiOperation(value = "修改数据")
    public Result<Void> update(@ApiParam(value = "领导干部参与操办本人及近亲属婚丧喜庆事宜情况报告表VO对象", required = true) @RequestBody UserHappyFuneralVO vo){
        service.updateUserHappyFuneral(vo);
        return Result.ok();
    }

    @DeleteMapping(value = "delete/{ids}")
    @ControllerLog(name = "逻辑删除领导干部参与操办本人及近亲属婚丧喜庆事宜情况", type = LogType.delete)
    @ApiOperation("逻辑删除")
    public Result<Void> delete(@ApiParam(value = "ID列表,用逗号分隔", required = true) @PathVariable(name="ids") String ids){
        if(StringUtils.isNotEmpty(ids)){
            service.removeByIds(Arrays.asList(ids.split(",")));
        }
        return Result.ok();
    }
}
